<%-- 
    Document   : descarga
    Created on : 15/02/2013, 05:45:33 AM
    Author     : johnny
--%>

<%@page import="java.io.FileInputStream"%>
<%@page import="java.io.BufferedInputStream"%>
<%@page import="java.io.InputStream"%>
<%@page import="java.io.File"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    String filename = request.getParameter("archivo");
    String nombre = request.getParameter("nombre");
    response.setContentType("APPLICATION/OCTET-STREAM");
    String disHeader = "Attachment; Filename='" + nombre + "'";
    response.setHeader("Content-Disposition", disHeader);
    InputStream in = null;
    ServletOutputStream outs = response.getOutputStream();
    
    try {
        in = new FileInputStream(filename);
        int i;
        while ((i = in.read()) != -1) {
            outs.write(i);
        }
    } finally {
        if (in != null) {
            in.close(); // very important
        }
    }

    outs.flush();
    outs.close();
    in.close();

%>
